package com.api.gbhg.daiyanlu.action;

import com.api.gbhg.daiyanlu.DataPrintCopyUtil.DataPrintCopy;
import com.api.gbhg.lbj.dao.GeneralProjectDao;
import com.api.gbhg.zengping.dao.PropertyManagementCostDao;
import com.api.gbhg.zengping.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

import java.util.HashMap;
import java.util.Map;

/**
 * 海关医疗保险缴费经费入库
 * Mr.dyl
 */
public class SixteenPut implements Action {
    private static final Logger log= LoggerFactory.getLogger(SixteenPut.class);
    @Override
    public String execute(RequestInfo requestInfo) {
        log.info("-------------海关医疗保险缴费经费开始入库---------------");
        PropertyManagementCostDao p=new PropertyManagementCostDao();
        String requestId=requestInfo.getRequestid();
        RecordSet rs= DataPrintCopy.getRs(requestInfo.getRequestid(),"uf_hgylbxjfjfxqbbb");
        Map<String, String> map = new HashMap<>();
        RecordSet recordSet = GeneralProjectDao.deleteWorkflowByid(requestId);
        recordSet.next();
        boolean b;
        for(b = false; rs.next(); b = p.insertBudgeLines(map)) {
            map.put("requestId",rs.getStringNoTrim("lcjlsqjlid"));
            map.put("lcbj",rs.getStringNoTrim("lcbj"));
            map.put("lcjlid",rs.getStringNoTrim("lcjlsqjlid"));
            map.put("nd",rs.getStringNoTrim("ysnd"));
            String yszje = rs.getStringNoTrim("yszje");
            if(yszje.isEmpty())
                yszje="0.00";
            map.put("ze",yszje);
            map.put("bmzcjjfl",rs.getStringNoTrim("bmyszcjjfl"));
            map.put("zfjjfl",rs.getStringNoTrim("dyzfjjfl"));
            map.put("syed",yszje);
            map.put("dj","0.00");
            map.put("sbdw",rs.getStringNoTrim("sbdw"));
            map.put("xmmc",rs.getStringNoTrim("xmmin"));
            map.put("modedatamodifier",rs.getStringNoTrim("jbr"));
            map.put("gkdw",rs.getStringNoTrim("gkdw"));
            map.put("sydw",rs.getStringNoTrim("sydw"));
            map.put("modedatamodifydatetime", DateUtil.getNowDate());
        }
        if (!b) {
            requestInfo.getRequestManager().setMessagecontent("海关医疗保险缴费经费入库失败");
            requestInfo.getRequestManager().setMessageid("1");
            log.info("同步流海关医疗保险缴费经费数据到入库表失败！");
            return "0";
        } else {
            return "1";
        }
    }
}
